﻿@model Think9.Models.UserEntity
@{ ViewBag.Title = "Edit";
    Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>基本信息</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <script language="javascript" type="text/javascript" src="~/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
    <form class="layui-form" lay-filter="formUser">
        <input type="text" name="Id" id="Id" style="display:none" value="@Model.Id">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="Account" placeholder="用户名" autocomplete="off" disabled class="layui-input" lay-verify="required" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <select id="Gender" name="Gender">
                        <option value="1">男</option>
                        <option value="0">女</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label  required">姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="RealName" placeholder="姓名" autocomplete="off" class="layui-input" lay-verify="required" maxlength="20">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-block">
                    <input type="text" name="MobilePhone" placeholder="手机号码" autocomplete="off" class="layui-input" maxlength="11" lay-verify='phone'>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="Email" placeholder="邮箱" autocomplete="off" class="layui-input" lay-verify='email'>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出生日期</label>
                <div class="layui-input-block">
                    <input type="text" name="Birthday" id="Birthday" placeholder="出生日期" autocomplete="off" class="layui-input" onClick="WdatePicker({ el: this,dateFmt: 'yyyy-MM-dd'})">
                </div>
            </div>
            <div class="layui-form-item" style="text-align:center;">
                <button class="layui-btn" lay-submit="" lay-filter="changeUser">编 辑</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(["form", "exLayer", "exUtils", "upload", "layer"], function () {
            let form = layui.form;
            let exLayer = layui.exLayer;
            let exUtils = layui.exUtils;
            let upload = layui.upload;
            let layer = layui.layer;
            let $ = layui.$;

            form.render(); //更新全部

        form.val("formUser", {
            "Account": "@Model.Account",
            "RealName": "@Model.RealName",
            "Gender": "@Model.Gender",
            "MobilePhone": "@Model.MobilePhone",
            "Email": "@Model.Email",
            "Birthday":showDate("@Model.Birthday")
        });

        form.on("submit(changeUser)", function (data) {
            exUtils.ajax("/Home/EditUser", "post", { model: data.field, id: $("#Id").val() }, true).done(function (response) {
                exLayer.greenTickMsg(response.message, function () {
                });
            }).fail(function (error) {
                console.log(error);
            });
            return false;
        });
     });
    </script>
</body>
</html>